/**
 * Created by c on 2017-11-20.
 */
//加载审核信息
function chstate(state){
    var $str;
    if(state==0){
        $str='<span style="color: cornflowerblue">待审核</span>';
    } else if(state==1){
        $str='<span style="color: green">已通过</span>';
    } else if(state==2){
        $str='<span style="color: red">未通过</span>';
    }
    return $str;
}

//搜索日期插件
$(function () {
    laydate.render({
        elem:'[name=startDate]'
    })
    laydate.render({
        elem:'[name=endDate]'
    })
    laydate.render({
        elem:'[name=subStrartdate]'
    })
    laydate.render({
        elem:'[name=subEnddate]'
    })
});

//模糊查询提交
function search(){
    var param={};
    param.planNum=$("input[name='planNum']").val();
    param.proName=$("input[name='proName']").val();
    param.subStrartdate=$("input[name='subStrartdate']").val();
    param.subEnddate=$("input[name='subEnddate']").val();
    param.startDate=$("input[name='startDate']").val();
    param.endDate=$("input[name='endDate']").val();
    $("#auditTable").bootstrapTable("refresh",{query:param});
}

function caozuo(){
    var $str = '<button type="button" class="layui-btn layui-btn-mini showDetail" >详情</button>';
    return $str;
}

window.optEvents= {
    "click .showDetail": function (e,value,row) {
        location.href = ctx+"/audit/searchOne?planNum="+row.planNum;
    }
}

$(function(){
    //设置table背景颜色
    $("table#delTable").children().find(".back").css({"background-color":"#F3F3F3"})
})
$(function () {
    $("[name=planChstate]").change(function () {
        $("#error").html("");
    })
})
function baocun(){
    var planChstate = $("[name=planChstate]").val();
    if(planChstate==-1){
        $("#error").html("请审核结果");
        return;
    }

    var param = $("form.auditInfo").serialize();
    //修改审核状态
    $.post(ctx+"/audit/auditpur",param,function(flag){
        if(flag=="true"){
            swal({
                title:"操作提示",
                text:"审核成功!",
                type:"success",
            }).then(function(){
                location.href=ctx+"/audit/puraudit/index";
            })
        } else {
            toastr.error("操作提示","系统出错,审核失败!");
        }
    },"text");
}

function fanhui(){
    location.href=ctx+"/audit/puraudit/index";
}
